//
//  EmojiKeyboard.swift
//  Kosspot
//
//  Created by 李鑫 on 2025/7/11.
//

import SwiftUI

// 1. 表情数据模型
struct Emoji {
    let symbol: String
    let name: String
}

class EmojiData: ObservableObject {
    @Published var emojis: [Emoji] = [
        Emoji(symbol: "😀", name: "大笑"),
        Emoji(symbol: "😎", name: "墨镜"),
        Emoji(symbol: "❤️", name: "爱心"),
        
        Emoji(symbol: "😀", name: "大笑1"),
        Emoji(symbol: "😎", name: "墨镜1"),
        Emoji(symbol: "❤️", name: "爱心1"),
        Emoji(symbol: "😀", name: "大笑2"),
        Emoji(symbol: "😎", name: "墨镜3"),
        Emoji(symbol: "❤️", name: "爱心4"),
        Emoji(symbol: "😀", name: "大笑5"),
        Emoji(symbol: "😎", name: "墨镜6"),
        Emoji(symbol: "❤️", name: "爱心7"),
        Emoji(symbol: "😀", name: "大笑8"),
        Emoji(symbol: "😎", name: "墨镜9"),
        Emoji(symbol: "❤️", name: "爱心0"),
        Emoji(symbol: "😀", name: "大笑11"),
        Emoji(symbol: "😎", name: "墨镜12"),
        Emoji(symbol: "❤️", name: "爱心13"),
        Emoji(symbol: "😀", name: "大笑14"),
        Emoji(symbol: "😎", name: "墨镜15"),
        Emoji(symbol: "❤️", name: "爱心16"),
        Emoji(symbol: "😀", name: "大笑17"),
        Emoji(symbol: "😎", name: "墨镜18"),
        Emoji(symbol: "❤️", name: "爱心19"),
        Emoji(symbol: "😀", name: "大笑20"),
        Emoji(symbol: "😎", name: "墨镜21"),
        Emoji(symbol: "❤️", name: "爱心22"),
        // 更多表情...
    ]
    
    func loadEmojis() {
        // 可扩展为从网络或本地加载
    }
}

// 2. 表情键盘视图
struct EmojiKeyboard: View {
    @ObservedObject var data: EmojiData
    @Binding var inputText: String
    let columns = [GridItem(.adaptive(minimum: 40))]
    
    var body: some View {
        ScrollView {
            LazyVGrid(columns: columns, spacing: 10) {
                ForEach(data.emojis, id: \.name) { emoji in
                    Button(action: {
                        inputText += emoji.symbol
                    }) {
                        Text(emoji.symbol)
                            .font(.system(size: 30))
                    }
                }
            }
            .padding()
        }
        .frame(width: Bounds.width,height: 368)
        .background(Color(hex: "#1E1E1E"))
    }
}
